using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace SellAvi.Model.AvitoSocketModels.Converters
{
    public class Float2IntegerConverter : DateTimeConverterBase
    {
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            writer.WriteRawValue(value.ToString());
        }

        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            int number;
            if (!int.TryParse(reader.Value.ToString(), out number))
                return null;
            return number;
        }
    }
}